package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CcsOfflineAppointmentPlace;
import com.ruoyi.system.service.ICcsOfflineAppointmentPlaceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线下预约地点Controller
 * 
 * @author ruoyi
 * @date 2024-10-28
 */
@RestController
@RequestMapping("/system/place")
public class CcsOfflineAppointmentPlaceController extends BaseController
{
    @Autowired
    private ICcsOfflineAppointmentPlaceService ccsOfflineAppointmentPlaceService;

    /**
     * 查询线下预约地点列表
     */
    @PreAuthorize("@ss.hasPermi('system:place:list')")
    @GetMapping("/list")
    public TableDataInfo list(CcsOfflineAppointmentPlace ccsOfflineAppointmentPlace)
    {
        startPage();
        List<CcsOfflineAppointmentPlace> list = ccsOfflineAppointmentPlaceService.selectCcsOfflineAppointmentPlaceList(ccsOfflineAppointmentPlace);
        return getDataTable(list);
    }

    /**
     * 导出线下预约地点列表
     */
    @PreAuthorize("@ss.hasPermi('system:place:export')")
    @Log(title = "线下预约地点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CcsOfflineAppointmentPlace ccsOfflineAppointmentPlace)
    {
        List<CcsOfflineAppointmentPlace> list = ccsOfflineAppointmentPlaceService.selectCcsOfflineAppointmentPlaceList(ccsOfflineAppointmentPlace);
        ExcelUtil<CcsOfflineAppointmentPlace> util = new ExcelUtil<CcsOfflineAppointmentPlace>(CcsOfflineAppointmentPlace.class);
        util.exportExcel(response, list, "线下预约地点数据");
    }

    /**
     * 获取线下预约地点详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:place:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(ccsOfflineAppointmentPlaceService.selectCcsOfflineAppointmentPlaceById(id));
    }

    /**
     * 新增线下预约地点
     */
    @PreAuthorize("@ss.hasPermi('system:place:add')")
    @Log(title = "线下预约地点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CcsOfflineAppointmentPlace ccsOfflineAppointmentPlace)
    {
        return toAjax(ccsOfflineAppointmentPlaceService.insertCcsOfflineAppointmentPlace(ccsOfflineAppointmentPlace));
    }

    /**
     * 修改线下预约地点
     */
    @PreAuthorize("@ss.hasPermi('system:place:edit')")
    @Log(title = "线下预约地点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CcsOfflineAppointmentPlace ccsOfflineAppointmentPlace)
    {
        return toAjax(ccsOfflineAppointmentPlaceService.updateCcsOfflineAppointmentPlace(ccsOfflineAppointmentPlace));
    }

    /**
     * 删除线下预约地点
     */
    @PreAuthorize("@ss.hasPermi('system:place:remove')")
    @Log(title = "线下预约地点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ccsOfflineAppointmentPlaceService.deleteCcsOfflineAppointmentPlaceByIds(ids));
    }
}
